Skip to main content

🐧 The Linux Filesystem

Now we learn one of the most important Linux concepts: how Linux organizes everything on your computer.

I'll explain it like you're 5, but we won't dumb down the actual concepts. The goal is for you to eventually look at a cloud server and know exactly where things belong.


🏠 1. Imagine Linux as a Giant House

Imagine your computer is a giant house.

In Windows, you might see:

C:\
β”œβ”€β”€ Users
β”œβ”€β”€ Program Files
└── Windows

Linux does things differently.

Linux starts from one giant starting point:

/

This is called the root of the filesystem.

Think of / as:

🏠 The main entrance to the entire Linux house.

Everything else lives underneath it.


🌳 2. The Linux Filesystem Tree

A simplified Linux filesystem looks like this:

/
β”œβ”€β”€ bin
β”œβ”€β”€ boot
β”œβ”€β”€ dev
β”œβ”€β”€ etc
β”œβ”€β”€ home
β”œβ”€β”€ lib
β”œβ”€β”€ media
β”œβ”€β”€ mnt
β”œβ”€β”€ opt
β”œβ”€β”€ proc
β”œβ”€β”€ root
β”œβ”€β”€ run
β”œβ”€β”€ sbin
β”œβ”€β”€ srv
β”œβ”€β”€ sys
β”œβ”€β”€ tmp
β”œβ”€β”€ usr
└── var

At first this looks scary.

Don't memorize everything yet.

For cloud engineering, these are particularly important:

/
β”œβ”€β”€ etc
β”œβ”€β”€ home
β”œβ”€β”€ root
β”œβ”€β”€ tmp
β”œβ”€β”€ usr
β”œβ”€β”€ var
β”œβ”€β”€ dev
β”œβ”€β”€ proc
└── opt

Let's understand them one by one.


🌍 3. / β€” The Root

The / directory is the top of the filesystem.

For example:

cd /

Now:

pwd

You should get:

/

And:

ls

might show:

bin
boot
dev
etc
home
lib
opt
proc
root
run
sbin
tmp
usr
var

Think:

/
β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
↓ ↓ ↓
home etc var
β”‚
↓
user

Everything begins at /.


🏑 4. /home β€” Users' Homes

Remember when we used:

cd ~

?

Your ~ points to your user's home directory.

For example:

/home/alex

The structure might look like:

/home
└── alex
β”œβ”€β”€ Documents
β”œβ”€β”€ Downloads
β”œβ”€β”€ Pictures
└── cloud

Each normal user generally gets a home directory.

You can check:

cd /home
ls

You might see:

alex

Then:

cd alex

That's your home.


πŸ‘‘ 5. /root β€” The Root User's Home

Here's an important distinction:

/

means:

The root of the entire filesystem.

/root​

means:

The home directory of the root user.

These are completely different things.

/
└── root/

Don't confuse:

/

with:

/root

Think:

/ = the whole house /root = the administrator's bedroom


βš™οΈ 6. /etc β€” Configuration

This directory is extremely important for system administration.

/etc contains system configuration files.

For example:

/etc
β”œβ”€β”€ hosts
β”œβ”€β”€ hostname
β”œβ”€β”€ ssh
β”œβ”€β”€ systemd
β”œβ”€β”€ passwd
└── ...

You can look at it:

ls /etc

You'll see many files and directories.

For example:

cat /etc/hostname

This usually displays your computer's hostname.

You can also inspect:

cat /etc/hosts

We'll learn exactly what that file does when we study networking.

🧠 Remember:​

/etc = configuration

When you're troubleshooting a Linux server, you'll visit /etc a lot.


πŸ“ 7. /var β€” Things That Change

/var stands for variable data.

Think:

"Stuff that changes while the computer is running."

It contains things such as:

  • Logs
  • Caches
  • Application data
  • Spool files

One especially important directory:

/var/log

That's where many Linux logs live.

Try:

ls /var/log

You may see things like:

syslog
auth.log
kern.log
...

The exact files depend on your Linux distribution.

Later, when we learn:

journalctl

and troubleshooting, /var/log will become very important.

🧠 Remember:​

/var = changing data

πŸ—‘οΈ 8. /tmp β€” Temporary Stuff

/tmp is for temporary files.

Imagine your desk.

You put something there temporarily while working on a project.

That's /tmp.

Try:

ls /tmp

You may see various temporary files.

Programs often use /tmp for temporary data.

🧠 Remember:​

/tmp = temporary files

Don't treat /tmp as permanent storage.


🧰 9. /usr β€” User-Space Programs & Data

This one can be confusing.

Historically, /usr was associated with "user" programs/data, but don't think of it simply as "my personal files."

Modern Linux systems commonly have things like:

/usr
β”œβ”€β”€ bin
β”œβ”€β”€ sbin
β”œβ”€β”€ lib
β”œβ”€β”€ share
└── local

For example:

ls /usr/bin

You'll see lots of programs.

Your system may have commands such as:

python3
git
curl
grep
ssh

located somewhere under /usr.

You can find where a command comes from with:

which ls

or, on many systems:

which python3

You might get:

/usr/bin/ls

🧠 Remember:​

/usr = many installed programs and shared data

🧰 10. /bin β€” Essential Commands

Historically, /bin contained essential user commands.

For example:

/bin
β”œβ”€β”€ ls
β”œβ”€β”€ cp
β”œβ”€β”€ mv
β”œβ”€β”€ rm
└── ...

On many modern Linux distributions, /bin is actually a symbolic link to something like:

/usr/bin

You don't need to worry about that yet.

Just remember:

/bin is associated with essential command-line programs.


πŸ”§ 11. /sbin β€” System Administration Commands

Similarly:

/sbin

traditionally contains system-administration programs.

For example, commands related to:

  • Networking
  • System management
  • Filesystems

Modern distributions may also merge /sbin into /usr/sbin.

Again, don't get stuck on the historical details.

Remember:

/bin β†’ general essential commands
/sbin β†’ system administration commands

🧩 12. /dev β€” Devices

This one is fascinating.

Linux treats many hardware devices like files.

That's why:

/dev

contains device representations.

Try:

ls /dev

You'll see things like:

null
zero
random
tty
...

You might see disks such as:

sda
nvme0n1

depending on the machine.

Why should a cloud engineer care?​

Because cloud servers have:

  • Virtual disks
  • Block devices
  • Network devices

When you're managing storage on a cloud VM, /dev becomes important.


🧠 13. /proc β€” Information About the Running System

/proc is special.

It isn't a normal directory full of ordinary files sitting on your disk.

Linux creates much of its contents dynamically to expose information about:

  • Processes
  • Memory
  • CPU
  • Kernel state

Try:

ls /proc

You'll see many numbers:

1
2
3
...

Those numbers are often process IDs (PIDs).

For example:

cat /proc/cpuinfo

gives information about your CPU.

Try:

cat /proc/meminfo

You'll get memory information.

🧠 Remember:​

/proc = information about the running Linux system

This will become extremely useful when we learn process troubleshooting.


πŸ’Ύ 14. /boot β€” Boot Files

When a computer starts, Linux needs certain files to boot.

Those are stored under:

/boot

You might see:

vmlinuz...
initramfs...
grub...

You don't need to modify these as a beginner.

Just remember:

/boot = files needed for booting Linux

πŸ“¦ 15. /opt β€” Optional/Additional Software

/opt is commonly used for additional or third-party software.

For example:

/opt/my-application

could contain an application installed outside the standard system locations.

Think:

"Extra software lives here."


πŸ”Œ 16. /mnt and /media

These directories are commonly associated with mounting filesystems.

/mnt​

Often used as a temporary/manual mount point.

Example concept:

/mnt/backup

/media​

Commonly used for automatically mounted removable media.

For cloud engineering, you'll eventually need to understand mounting disks, so these directories will make more sense later.


πŸš€ 17. /srv

/srv can be used for data served by system services.

For example, a server might store certain website/service data under:

/srv

It's less important for you right now than /etc, /var, /home, and /usr.


🧠 The Big Cheat Sheet

Don't memorize every directory today.

Memorize this:

DirectoryThink
/🌍 Everything
/home🏠 Normal users
/rootπŸ‘‘ Root user's home
/etcβš™οΈ Configuration
/varπŸ“ˆ Changing data/logs
/tmpπŸ—‘οΈ Temporary files
/usr🧰 Programs/shared data
/binπŸ”§ Essential commands
/sbinπŸ› οΈ System commands
/devπŸ’Ύ Devices
/proc🧠 Running system/process info
/bootπŸš€ Boot files
/optπŸ“¦ Optional software
/mntπŸ”Œ Mount point
/mediaπŸ’Ώ Removable media
/srv🌐 Service data

🧭 Absolute vs Relative Paths

This is very important.

Suppose you're here:

/home/alex/cloud

And you want:

/home/alex/cloud/linux

You can use:

cd linux

That's a relative path.

You're saying:

"From where I am now, go into linux."

But you could also write:

cd /home/alex/cloud/linux

That's an absolute path.

You're saying:

"Start at / and follow this exact path."


πŸ” How to Recognize Them

Absolute path​

Starts with /:

/home/alex/cloud
/etc/hosts
/var/log
/usr/bin

Relative path​

Doesn't start with /:

cloud
linux/notes.txt
../Documents

This distinction is essential when writing scripts and managing servers.


πŸ§ͺ Your Filesystem Lab

Now let's explore your Linux machine.

Run these one at a time:

pwd

Then:

ls /

Then:

ls /home

Then:

ls /etc

Then:

ls /var

Then:

ls /var/log

Then:

ls /usr/bin | head

And finally:

cat /etc/hostname

One particularly important experiment:​

Run:

cd /

Then:

pwd

You should get:

/

Now run:

cd /tmp

Then:

pwd

You should get:

/tmp

Now:

cd ..

Where do you think you are?

Run:

pwd

Don't just guessβ€”predict first, then run it.


🎯 Mini Challenge

Without looking back at the explanations, answer these:

  1. Where are normal users' home directories stored?
  2. Where would you look for system configuration?
  3. Where would you look for logs?
  4. Where are temporary files generally stored?
  5. What is /root?
  6. What is /?
  7. What's the difference between /home/user and home/user?
  8. Where can you find information about running processes?
  9. Where are device representations found?
  10. What does .. mean?

Once you've done the lab, send me your answers + any command output that surprised you.

Then we'll move to Lesson #3: Linux files, permissions, users, groups, and the mysterious -rwxr-xr-x. That's where you'll start understanding what those weird Linux permission strings actually mean.